/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUI;

import Model.Gates.Gate;
import Model.Gates.Led;
import java.awt.Dimension;
import java.awt.Point;
import java.util.ArrayList;
import javax.imageio.ImageIO;
import javax.swing.JOptionPane;

/**
 *
 * @author bg
 */
public class LedView extends AbstractElementView {

    Led led;

    public LedView(Led ledi, Point position) {
        inputs = new ArrayList<Point>();

        try {
            img = ImageIO.read(getClass().getResource("Images/led.png"));
        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nincsen LED kép!");
        }
        this.led = ledi;
        this.position = position;
        this.preferredImageSize = new Dimension(30, 64);
        for (int i = Math.round(64 / (led.getMaxInput() + 1)); i < 60; i += Math.round(64 / (led.getMaxInput() + 1))) {
            inputs.add(new Point(position.x, position.y + i));
        }
        

    }

    void tick() {
        try {
            if (led.getVal() == false) {
                img = ImageIO.read(getClass().getResource("Images/led.png"));
            } else {
                img = ImageIO.read(getClass().getResource("Images/led1.png"));
            }

        } catch (Exception e) {
            JOptionPane.showMessageDialog(null, "Nincsen " + this.getClass().getName() + " kép!!!");
        }
    }
    

    @Override
    Gate getGate() {
        return led;
    }
}
